import { InjectionKey } from 'vue'
import { createStore, Store, useStore as baseUseStore } from 'vuex'
import common from './modules/common'
import createPersistedstate from 'vuex-persistedstate'

export interface State {}

// 定义 injection key
export const zwScrm: InjectionKey<Store<State>> = Symbol()

const plugins = [
  createPersistedstate({paths: ['common']})
]

export const store = createStore<State>({
  strict: false,
  modules: {
    common
  },
  plugins
})

// 自定义 `useStore` 组合式函数
export function useStore() {
  return baseUseStore(zwScrm)
}
